var mongoose = require("mongoose");
var Schema=mongoose.Schema;

async function dbInit(){
    try{
        await mongoose.connect("mongodb://59.110.105.217:27017/catchfish",{useNewUrlParser:true,useUnifiedTopology:true});
        console.log("数据库连接成功")
    }catch{
        console.log("服务器连接失败")
    }
}
var UserData=new Schema({
    username:{
        type:String,
        unique:true,
    },
    password:{type:String},
    level:{type:Number},
});
// var GradesData = new Schema({
//     _id:String,
//     name:String,
//     class:String,
//     Math:Number,
//     English:Number,
//     Chinese:Number
// })
var User = mongoose.model("user",UserData);
// var Grades= mongoose.model("list",GradesData)
module.exports={dbInit,User}




